#include "MaskedBlurredSprite.h"

MaskedBlurredSprite::MaskedBlurredSprite(void)
{
}

MaskedBlurredSprite::MaskedBlurredSprite(BITMAP *_src, BITMAP *_dest, signed int _x, signed int _y, unsigned int _width, unsigned int _height, bool _alphaBlended,  unsigned int _maskX, unsigned int _maskY):
MotionBlurredSprite(_src, _dest, _x, _y, _width, _height, _alphaBlended),
maskX(_maskX),
maskY(_maskY)
{
	sBitmap = create_sub_bitmap(_src, maskX, maskY, _width, _height);
}

MaskedBlurredSprite::~MaskedBlurredSprite(void)
{
	destroy_bitmap(sBitmap);
}

void MaskedBlurredSprite::draw()
{
	currentDelay ++;
	if(currentDelay > delay)
	{
		for(unsigned int i = 0; i <= (numberOfTraces - 1); i++)
		{
			lastX[numberOfTraces-i] = lastX[numberOfTraces -1 -i];
			lastY[numberOfTraces-i] = lastY[numberOfTraces -i - 1];
		}
		currentDelay = 0;
	}

	lastX[0] = x;
	lastY[0] = y;

	set_trans_blender(0, 0, 0, 255);
	draw_trans_sprite(dest, sBitmap, lastX[0], lastY[0]);

	for(unsigned int i = 1; i <= numberOfTraces; i++)
	{
		set_trans_blender(0, 0, 0, 180 - i*30);
		draw_trans_sprite(dest, sBitmap, lastX[i], lastY[i]);
	}

	set_alpha_blender();
}
